﻿<UserControl x:Class="BizControl.Presentation.PersonMarkEditModule.Views.PersonMarkEditView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:res="clr-namespace:BizControl.Presentation.Infrastructure.Properties;assembly=BizControl.Presentation.Infrastructure"
             xmlns:csla="clr-namespace:Csla.Xaml;assembly=Csla.Xaml"
             xmlns:controls="clr-namespace:BizControl.Presentation.Infrastructure.Controls;assembly=BizControl.Presentation.Infrastructure"
             xmlns:infra="clr-namespace:BizControl.Presentation.Infrastructure.Controls;assembly=BizControl.Presentation.Infrastructure"
             Name="PersonMarkEditViewControl">

    <StackPanel>

        <ToolBar>
            <Button x:Name="SaveButton" HorizontalAlignment="Left" 
                    VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"
                    Width="25" Height="25" ToolTip="Сохранить"
                    IsEnabled="{Binding CanSave}"
                    Template="{StaticResource OkButtonTemplate}">
            </Button>
            <csla:TriggerAction TargetControl="{Binding ElementName=SaveButton}" MethodName="Save"/>
            <Button HorizontalAlignment="Right" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"
                    Width="25" Height="25" ToolTip="Закрыть"
                    Command="{Binding Path=CloseCommand}"
                    Template="{StaticResource CancelButtonTemplate}">
            </Button>
        </ToolBar>
        <TabControl Margin="2,2,8,8" Grid.Row="1"
                    HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
                    ItemContainerStyle="{StaticResource CustomTabItemStyle}">
            <TabItem>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="160" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>

                    <TextBlock Grid.Row="0" Text="Наименование навыка:" VerticalAlignment="Center" FontWeight="Bold" />
                    <StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Left">
                        <TextBox VerticalContentAlignment="Center" Width="150" Margin="2" TextWrapping="Wrap"
                                 Text="{Binding Path=Model.Name, UpdateSourceTrigger=PropertyChanged}" />
                        <csla:PropertyStatus Margin="5" DataContext="{Binding Model}" Property="{Binding Path=Name}"/>
                        <Expander Header="Свойства маркера" IsExpanded="True"
                                  Visibility="{Binding Path=Model.HasDetails, Converter={StaticResource BoolToVisibilityConverter}}">
                            <DataGrid AutoGenerateColumns="False" ItemsSource="{Binding Path=Model.Details}">
                                <DataGrid.Columns>
                                    <DataGridTextColumn Binding="{Binding Path=Name}" Header="Наименование свойства" />
                                    <DataGridTextColumn Binding="{Binding Path=Value}" Header="Значение свойства" />
                                    <DataGridTemplateColumn Header="Создано">
                                        <DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <Image Stretch="Uniform" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Height="40" Width="40"
                                                       Source="{Binding Path=CreatedBy.Photo, Mode=OneWay, Converter={StaticResource ImageConverter}}" />
                                            </DataTemplate>
                                        </DataGridTemplateColumn.CellTemplate>
                                    </DataGridTemplateColumn>
                                </DataGrid.Columns>
                            </DataGrid>
                        </Expander>
                    </StackPanel>
                </Grid>
            </TabItem>
        </TabControl>
    </StackPanel>
</UserControl>
